home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: nntp.coast.net!torn!nott!cunews!wabakimi!jarthorn
- From: jarthorn@chat.carleton.ca (John Arthorne)
- Subject: Re: Character String --> Integer
- X-Nntp-Posting-Host: wabakimi.carleton.ca
- Message-ID: <DMFFoF.8BF@cunews.carleton.ca>
- Sender: news@cunews.carleton.ca (News Administrator)
- Organization: Carleton University
- X-Newsreader: TIN [version 1.2 PL2]
- References: <4fb0ga$lsa@remus.rutgers.edu>
- Date: Wed, 7 Feb 1996 22:26:39 GMT
-
- Force Of Nature (wempa@remus.rutgers.edu) wrote:
- > Is there an easy way to convert a character string such as '2425' to the
- > integer 2425 ??? The only way I can think of is to pick off characters
- > one at a time and use switch statements to determine the value (0-9) and
- > then multiply by the correct power of 10. Is there an easier way to do
- > this ???????
-
- The function atoi() /* ascii-to-integer */ will convert your string to the
- desired integer. Supply the function with your string address and atoi()
- will cut off any trailing non-numeric characters and convert the rest to
- an integer.
-
- John Arthorne
- jarthorn@chat.carleton.ca
-
-